﻿using KMF.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace KMF.DAL
{
    public partial class AttributeDb
    {
        // Attr FIL
        public static List<AttrFilterDto> GetAttrFilter(CategoryFilterModel modelFil)
        {
            var dao = SharedSqlDao;
            var command = dao.GetDbSprocCommand("WSPX_Attr_SelectByFilter");
            try
            {
                command.Parameters.Add(dao.CreateParameter("@CategoryId", modelFil.CategoryId));
                command.Parameters.Add(dao.CreateParameter("@PriceMin", modelFil.PriceMin));
                command.Parameters.Add(dao.CreateParameter("@PriceMax", modelFil.PriceMax));
                command.Parameters.Add(dao.CreateParameter("@RateMin", modelFil.RateMin));
                command.Parameters.Add(dao.CreateParameter("@RateMax", modelFil.RateMax));
                command.Parameters.Add(dao.CreateParameter("@Providers", modelFil.Providers));
                command.Parameters.Add(dao.CreateParameter("@Colors", modelFil.Colors));
                command.Parameters.Add(dao.CreateParameter("@Sizes", modelFil.Sizes));
                command.Parameters.Add(dao.CreateParameter("@Attrs", modelFil.Attrs));

                var result = dao.GetDTOList<AttrFilterDto>(ref command);
                return result;
            }
            finally
            {
                command.Connection.Close();
            }
        }
    }
}
